import React, {Component} from 'react';
import {
  View,
  Text,
  TouchableOpacity,
  ScrollView,
  Keyboard,
  Alert,
} from 'react-native';

import Config from '../../config';
import Constants from '../../common/Constants';
import ToastUtils from '../../common/ToastUtils';
import SizeUtils from '../../common/SizeUtils';
import CommonInputPage from '../common/CommonInputPage';
import ActivityRequestEnterAction from '../../actions/activity/ActivityRequestEnterAction';

const INPUT_DEFAULT = "请输入你的报名宣言";

export default class ActivityEnterSingerDeclarationPage extends CommonInputPage {
  constructor(props) {
    super(props);

    this.enterData = this.props.pageData.routeData.enterData;
  }

  _dealEnterPage() {
    super._dealEnterPage()
    this.enterData = this.props.pageData.routeData.enterData;
  }

  componentWillUpdate(nextProps, nextState) {
    super.componentWillUpdate(nextProps, nextState);
    if(nextState.statusText != this.state.statusText) {
      ToastUtils.show(nextState.statusText);
    }
    if(nextState.enter_state == 2) {
      nextState.enter_state = 0;
      this.goBackIndex(1);
    }
  }

  _doSubmit() {
    Alert.alert('提示', "是否确认报名", [
        {text:'确定',onPress:()=>{this._onApplicantSubmit()}},
        {text:'取消',onPress:()=>{}}
      ])
  }

  _onApplicantSubmit() {
    this.enterData.content = this.state.content;
    this.enterData.type = "enter";
    new ActivityRequestEnterAction().call(this, this.enterData);
  }

  _getTitle() {
    var text = "Title";
    if(this.props.pageData.title) {
      text = this.props.pageData.title;
    }
    return text;
  }
}
